<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Admin\Business\Repository\Combo;
use App\Repositories\ScenicRepository;
use App\Scenic;
use App\ScenicBuy;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class FileController extends Controller
{
    public function index(Request $request,$filename){//检查文件权限

        $scenic=Scenic::where('voice',$filename)->first();

        if($scenic){


           if(Auth::guard('member')->user()->can('buy',$scenic)){

               return response()->file(storage_path('app/file/'.$filename));
           }
        }
        return 'no result';
    }
    public function  menu(){
        $menu=app('wechat')->menu;

        $bottons=[
                [
                    'name'=>'景点讲解',
                    'sub_button'=>[
                        [
                        'type'=>'view',
                        "name"=>'景点讲解',
                        'url'=>'http://wx.tianluoly.com/scenic/shake',
                        'sub_button'=>[]
                            ],
                        [
                            'type'=>'view',
                            "name"=>'景点试听',
                            'url'=>'http://wx.tianluoly.com/scenic/shakeTest',
                            'sub_button'=>[]
                        ]
                    ]
                ],

         /*   [
                'type'=>'view',
                'name'=>'购买套餐',
                'url'=>'',
                'sub_button'=>'',
            ],*/
            [
                'name'=>'购买讲解',
                'sub_button'=>[
                    [
                        'type'=>'view',
                        "name"=>'单独购买',
                        "url" => "http://wx.tianluoly.com/combo/list",
                        'sub_button'=>[]
                    ],
                    [
                        'type'=>'view',
                        "name"=>'套票兑换',
                        "url" => "http://wx.tianluoly.com/exchange",
                        'sub_button'=>[]
                    ]
                ]
            ],
            [
                'name'=>'个人中心',
                'sub_button'=>[
                    [
                        'type'=>'view',
                        "name"=>'我的推广',
                        'url'=>"http://wx.tianluoly.com/user/group",
                        'sub_button'=>[]
                    ],
                    [
                        'type'=>'view',
                        "name"=>'我的信息',
                        'url'=>'http://wx.tianluoly.com/user',
                        'sub_button'=>[]
                    ]
                ]
            ]

        ];
        dd($menu->add($bottons));
    }
}
